package com.hhss.qishi.DPtest.designpattern.singleton;

/**
 * 单件模式
 */
public class Singleton {

    private volatile static Singleton uniqueInstance;
    private String name;

    /**
     * 私有化构造器，拒绝对象创建
     */
    private Singleton(){}

    public static Singleton getInstance(){
        if(uniqueInstance == null){
            synchronized (Singleton.class){
                if(uniqueInstance == null){
                    return uniqueInstance = new Singleton();
                }
            }


        }

        return uniqueInstance;
    }

    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }
}
